import Vue from 'vue'
import Vuex from 'vuex'
import taskCreate from './taskCreate'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    userId: 0,
    deviceId: 0,
    permission: {},
    orgIds: 0,
    workType: [],
    station: 0,
    taskSetting: {},
    myStationIds: [],
    stationIds: []
  },
  mutations: {
    setUserId(state, userId) {
      state.userId = userId
    },
    setDeviceId(state, deviceId) {
      state.deviceId = deviceId
    },
    setPermission(state, permission) {
      state.permission = permission
    },
    setOrgIds(state, orgIds) {
      state.stationIds = orgIds
    },
    setStationIds(state, stationIds) {
      state.stationIds = stationIds
    },
    setMyStationIds(state, myStationIds) {
      state.myStationIds = myStationIds
    },
    setWorkType(state, workType) {
      state.workType = workType
    },
    setStation(state, station) {
      state.station = station
    },
    setTaskSetting(state, taskSetting) {
      state.taskSetting = taskSetting
    }
  },
  actions: {
    setConfig({ commit }, configJson) {
      commit('setTaskSetting', configJson.taskSetting)
    }
  },
  getters: {
    userId: (state) => state.userId,
    deviceId: (state) => state.deviceId,
    permission: (state) => state.permission,
    orgIds: (state) => state.orgIds,
    stationIds: (state) => state.stationIds,
    myStationIds: (state) => state.myStationIds,
    workType: (state) => state.workType,
    station: (state) => state.station,
    taskSetting: (state) => state.taskSetting
  },
  modules: {
    taskCreate
  }
})
